version 13
#delimit;
clear all;
set more off;
capture log close;


global strformat "%8.3f";

capture program drop sig_p;
program sig_p;
   args obj_var point_est_var point_sd_var p_val row_id_var row_num;
   local point_est `point_est_var';
   local point_sd `point_sd_var';
   if `p_val' > 0.1 {;
      replace `obj_var' = string(`point_est', "$strformat") if `row_id_var' == `row_num';
      };
   if `p_val' > 0.05 & `p_val' <= 0.1  {;
      replace `obj_var' = string(`point_est', "$strformat")+"*" if `row_id_var' == `row_num';
      };
   if `p_val' > 0.01 & `p_val' <= 0.05  {;
      replace `obj_var' = string(`point_est', "$strformat")+"**" if `row_id_var' == `row_num';
      };
   if `p_val' <= 0.01 {;
      replace `obj_var' = string(`point_est', "$strformat")+"***" if `row_id_var' == `row_num';
      };
   replace `obj_var' = "<" + string(`point_sd', "$strformat") + ">" + " " if `row_id_var' == `row_num' + 1;
   end;


*enter directory name here;

use "$dir/ReStat_children.dta", clear;


global fu_child_controls_cm
	"control_fu_child_age control_fu_female
	missing_fu_child_age missing_fu_female";
		
global fu_hh_controls_cm
	"control_fu_adults control_fu_hh_head_edu control_fu_hh_head_occ_farmer 
	control_fu_total_land control_fu_household_size
	missing_fu_adults missing_fu_hh_head_edu missing_fu_hh_head_occ_farmer 
	missing_fu_total_land missing_fu_household_size";


	


generate row_num = _n;

forvalues i=0/25 {;
	generate col`i' = "";
};

local row = 4;
sort row_num;
order col0-col25;



su village_level if village_level == 1 & pooled_treatment == 0;
replace col2 = string(r(N)) if row_num == `row';
replace col0 = "# villages" if row_num == `row';
local row = `row' + 3;



su census_household_w_child if pooled_treatment == 0;
replace col2 = string(r(N)) if row_num == `row';
replace col0 = "# census hhs w/child" if row_num == `row';
local row = `row' + 1;
su fu1c_child if fu1c_child_level == 1 & pooled_treatment == 0 & fu1c_child == 1;
replace col2 = string(r(N)) if row_num == `row';
replace col0 = "# young children" if row_num == `row';
local row = `row' + 3;


su followup_household if pooled_treatment == 0;
replace col2 = string(r(N)) if row_num == `row';
replace col0 = "# followup households" if row_num == `row'; 
local row = `row' + 1;
su fu_child if fu_child_level == 1 & pooled_treatment == 0 & fu_child == 1;
replace col2 = string(r(N)) if row_num == `row';
replace col0 = "# followup young children" if row_num == `row';
local row = `row' + 3;



local row = 4;


/**************
pooled treatment
****************/


su village_level if village_level == 1 & pooled_treatment == 1;
replace col4 = string(r(N)) if row_num == `row';
local row = `row' + 3;



su census_household_w_child if pooled_treatment == 1;
replace col4 = string(r(N)) if row_num == `row';
local row = `row' + 1;
su fu1c_child if fu1c_child_level == 1 & pooled_treatment == 1 & fu1c_child == 1;
replace col4 = string(r(N)) if row_num == `row';
local row = `row' + 3;


su followup_household if pooled_treatment == 1;
replace col4 = string(r(N)) if row_num == `row';
local row = `row' + 1;
su fu_child if fu_child_level == 1 & pooled_treatment == 1 & fu_child == 1;
replace col4 = string(r(N)) if row_num == `row';
local row = `row' + 3;



local row = 4;




/**************
treatment 1
****************/


su village_level if village_level == 1 & treatment_1 == 1;
replace col5 = string(r(N)) if row_num == `row';
local row = `row' + 3;



su census_household_w_child if treatment_1 == 1;
replace col5 = string(r(N)) if row_num == `row';
local row = `row' + 1;
su fu1c_child if fu1c_child_level == 1 & treatment_1 == 1 & fu1c_child == 1;
replace col5 = string(r(N)) if row_num == `row';
local row = `row' + 3;


su followup_household if treatment_1 == 1;
replace col5 = string(r(N)) if row_num == `row';
local row = `row' + 1;
su fu_child if fu_child_level == 1 & treatment_1 == 1 & fu_child == 1;
replace col5 = string(r(N)) if row_num == `row';
local row = `row' + 3;



local row = 4;





/**************
treatment 2
****************/


su village_level if village_level == 1 & treatment_2 == 1;
replace col6 = string(r(N)) if row_num == `row';
local row = `row' + 3;



su census_household_w_child if treatment_2 == 1;
replace col6 = string(r(N)) if row_num == `row';
local row = `row' + 1;
su fu1c_child if fu1c_child_level == 1 & treatment_2 == 1 & fu1c_child == 1;
replace col6 = string(r(N)) if row_num == `row';
local row = `row' + 3;


su followup_household if treatment_2 == 1;
replace col6 = string(r(N)) if row_num == `row';
local row = `row' + 1;
su fu_child if fu_child_level == 1 & treatment_2 == 1 & fu_child == 1;
replace col6 = string(r(N)) if row_num == `row';
local row = `row' + 3;


local row = 4;




/**************
all
****************/


su village_level if village_level == 1 & pooled_treatment ~= .;
replace col8 = string(r(N)) if row_num == `row';
local row = `row' + 3;



su census_household_w_child if pooled_treatment ~= .;
replace col8 = string(r(N)) if row_num == `row';
local row = `row' + 1;
su fu1c_child if fu1c_child_level == 1 & pooled_treatment ~= . & fu1c_child == 1;
replace col8 = string(r(N)) if row_num == `row';
local row = `row' + 3;


su followup_household if pooled_treatment ~= .;
replace col8 = string(r(N)) if row_num == `row';
local row = `row' + 1;
su fu_child if fu_child_level == 1 & pooled_treatment ~= . & fu_child == 1;
replace col8 = string(r(N)) if row_num == `row';
local row = `row' + 3;



local row = `row' + 2;




outsheet col0-col8 using "$dir/Table 1 Sample Size Coverage.csv" if
	row_num <= `row', comma replace;

